package demo3;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: WHY
 * Date: 2022-11-16
 * Time: 13:48
 */
abstract class Animal{
    public String name;

    public Animal(String name) {
        this.name = name;
    }
}
interface IRunning{
    void run();
}
interface ISwimming{
    void swim();
}
interface IFly{
    void fly();
}
class Dog extends Animal  implements  IRunning{
    public Dog(String name) {
        super(name);
    }

    @Override
    public void run() {
        System.out.println(name+"正在跑");
    }

}
class Duck extends Animal implements  IFly,IRunning,ISwimming{
    public Duck(String name) {
        super(name);
    }

    @Override
    public void run() {
        System.out.println(name+"正在跑");
    }

    @Override
    public void fly() {
        System.out.println(name+"正在飞");
    }

    @Override
    public void swim() {
        System.out.println(name+"正在游泳");
    }
}
class  robot implements ISwimming{
    public String name;

    public robot(String name) {
        this.name = name;
    }

    @Override
    public void swim() {
        System.out.println(name+"机器人在游泳");
    }
}


public class TestDemo {
    public static void walk(IRunning iRunning){
        iRunning.run();
    }
    public static void swim(ISwimming iSwimming){
        iSwimming.swim();
    }
    public static void main(String[] args) {
        walk(new Dog("贝贝"));
        walk(new Duck("丫丫"));
        swim(new Duck("丫丫1"));
        swim(new robot("小冰"));

    }

}
